require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '10.0'

target 'react_native_basic_framework' do
  config = use_native_modules!

  use_react_native!(:path => config["reactNativePath"])

  target 'react_native_basic_frameworkTests' do
    inherit! :complete
    # Pods for testing
  end

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable these next few lines.
  #  use_flipper!({ 'Flipper-Folly' => '2.3.0' })
  #  post_install do |installer|
  #    flipper_post_install(installer)
  #  end
  #⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄修复iOS 14.5新建RN0.64无法运行⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄⌄
  def find_and_replace(dir, findstr, replacestr)
    Dir[dir].each do |name|
      text = File.read(name)
      replace = text.gsub(findstr,replacestr)
      if text != replace
        puts "Fix: " + name
        File.open(name, "w") { |file| file.puts replace }
        STDOUT.flush
      end
    end
    Dir[dir + '*/'].each(&method(:find_and_replace))
   end

   post_install do |installer|
     flipper_post_install(installer)
     find_and_replace("Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h",
     "atomic_notify_one(state)", "folly::atomic_notify_one(state)")

     find_and_replace("Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h",
     "atomic_wait_until(&state, previous | data, deadline)", "folly::atomic_wait_until(&state, previous | data, deadline)")
   end
  #⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃修复iOS 14.5新建RN0.64无法运行⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃⌃
end


